package folder.model.virtual;

import java.util.ArrayList;
import java.util.List;

import folder.model.node.Node;

public class VirtualNode
{	
	// Virtual node
	
	public static VirtualNode virtualNode( int identifier, VirtualNetwork virtualNetwork )
	{
		return new VirtualNode( identifier, virtualNetwork );
	}
	
	public VirtualNode( int identifier, VirtualNetwork virtualNetwork )
	{
		this.identifier = identifier;
		this.virtualNetwork = virtualNetwork;
	}
	
	private final int identifier;
	public int getIdentifier(){ return this.identifier; }
    public String toString()
    {
    	String string = Integer.toString( identifier );// + "(" + this.node.getIdentifier() +")";
    	
    	return string;
    }
	
	private final VirtualNetwork virtualNetwork;
	public VirtualNetwork getVirtualNetwork(){ return this.virtualNetwork; }
	
	private final List< VirtualLink > virtualLinks = new ArrayList< VirtualLink >();
	public List< VirtualLink > getVirtualLinks(){ return this.virtualLinks; }
	public void addVirtualLink( VirtualLink virtualLinkToAdd ){ this.virtualLinks.add( virtualLinkToAdd ); }
	
	// Allocation
	
	private Node node;
	public Node getNode(){ return this.node; }
	
	public void allocate( Node node )
	{
		node.allocate( this );
		this.node = node; 
	}
	
	public void release()
	{
		if( node != null )
			node.release( this );
		
		this.node = null;
	}
	    
}
